package com.yanze.schoolinformation.model.http.reqo;

import com.yanze.schoolinformation.model.bean.GankDataBean;
import com.yanze.schoolinformation.model.bean.HotMovieBean;
import com.yanze.schoolinformation.model.bean.MovieDetailBean;
import com.yanze.schoolinformation.model.bean.QsbkListBean;
import com.yanze.schoolinformation.model.bean.WanAndroidBannerBean;
import com.yanze.schoolinformation.model.bean.WanAndroidListBean;
import com.yanze.schoolinformation.model.bean.book.BookBean;
import com.yanze.schoolinformation.model.bean.book.BookDetailBean;
import com.yanze.schoolinformation.model.bean.req.ReqBookCommit;
import com.yanze.schoolinformation.model.bean.req.ReqCommitDynamic;
import com.yanze.schoolinformation.model.bean.req.ReqDynamics;
import com.yanze.schoolinformation.model.bean.req.ReqIssue;
import com.yanze.schoolinformation.model.bean.req.ReqLostedthing;
import com.yanze.schoolinformation.model.bean.req.ReqSecondBook;
import com.yanze.schoolinformation.model.bean.req.ReqUser;
import com.yanze.schoolinformation.model.bean.resp.RespBook;
import com.yanze.schoolinformation.model.bean.resp.RespBookCommit;
import com.yanze.schoolinformation.model.bean.resp.RespCurr;
import com.yanze.schoolinformation.model.bean.resp.RespDynamic;
import com.yanze.schoolinformation.model.bean.resp.RespDynamicCommit;
import com.yanze.schoolinformation.model.bean.resp.RespHomeBanner;
import com.yanze.schoolinformation.model.bean.resp.RespImage;
import com.yanze.schoolinformation.model.bean.resp.RespLosted;
import com.yanze.schoolinformation.model.bean.resp.RespUser;
import com.yanze.schoolinformation.model.http.RetrofitClient;

import io.reactivex.Observable;
import okhttp3.MultipartBody;

/**
 * Created by MrZheng on 2018/4/4.
 */

public class DataReqo extends BaseReqo {
    private static volatile DataReqo mInstant;

    private DataReqo() {
    }

    public static DataReqo getInstant() {
        if (mInstant == null) {
            synchronized (DataReqo.class) {
                if (mInstant == null) {
                    mInstant = new DataReqo();
                }
            }
        }
        return mInstant;
    }

    //测试
    public Observable<String> getString(String baseUrl) {
        return transform(RetrofitClient.DATA(baseUrl).getString("1"));
    }

    //获取豆瓣Top250电影
    public Observable<HotMovieBean> getTop250Movie(String baseUrl, int start, int count) {
        return transform(RetrofitClient.DATA(baseUrl).getMovieTop250(start, count));
    }

    //获取电影详情
    public Observable<MovieDetailBean> getMovieDetail(String baseUrl, String id) {
        return transform(RetrofitClient.DATA(baseUrl).getMovieDetail(id));
    }

    //获取热门电影
    public Observable<HotMovieBean> getHotMovie(String baseUrl) {
        return transform(RetrofitClient.DATA(baseUrl).getHotMovie());
    }


    /**
     * 根据Tag获取图书
     */
    public Observable<BookBean> getBookByTag(String baseUrl, String tag, int start, int count) {
        return transform(RetrofitClient.DATA(baseUrl).getBookByTag(tag, start, count));
    }

    //获取图书详情
    public Observable<BookDetailBean> getBookDetail(String baseUrl, String id) {
        return transform(RetrofitClient.DATA(baseUrl).getBookDetail(id));
    }


    /**
     * 获取干货定制内容
     */
    public Observable<GankDataBean> getGankIoData(String baseUrl, String type, int pre_page, int page) {
        return transform(RetrofitClient.DATA(baseUrl).getGankIoData(type, pre_page, page));
    }

    /**
     * 获取玩安卓Banner图
     */
    public Observable<WanAndroidBannerBean> getWanAndroidBanner(String baseUrl) {
        return transform(RetrofitClient.DATA(baseUrl).getWanAndroidBanner());
    }

    //获取玩安卓列表
    public Observable<WanAndroidListBean> getWanaAndroidList(String baseUrl, int page) {
        return transform(RetrofitClient.DATA(baseUrl).getWanaAndroidList(page));
    }

    /**
     * 糗事百科
     */
    public Observable<QsbkListBean> getQsbkList(String baseUrl, int page) {
        return transform(RetrofitClient.DATA(baseUrl).getQsbkList(page));
    }


    //============================我的服务器

    /**
     * 注册
     */
    public Observable<RespUser> register(String baseUrl, ReqUser user) {
        return transform(RetrofitClient.DATA(baseUrl).register(user));
    }

    /**
     * 登录
     */
    public Observable<RespUser> login(String baseUrl, String phone, String password) {
        return transform(RetrofitClient.DATA(baseUrl).login(phone, password));
    }

    /**
     * 修改头像
     */
    public Observable<RespUser> upHeader(String baseUrl, String userid, MultipartBody.Part requestBody) {
        return transform(RetrofitClient.DATA(baseUrl).upheader(userid, requestBody));
    }

    /**
     * 修改用户信息
     */
    public Observable<RespUser> modify(String baseUrl, String userid, String nickname, String userqq, String userwechat) {
        return transform(RetrofitClient.DATA(baseUrl).modify(userid, nickname, userqq, userwechat));
    }

    /**
     * 根据userid获取用户信息
     */
    public Observable<RespUser> getUserById(String baseUrl, String userid) {
        return transform(RetrofitClient.DATA(baseUrl).getUserInfoById(userid));
    }

    /**
     * 上传单个图片
     */
    public Observable<RespImage> upImage(String baseUrl, MultipartBody.Part requestBody) {
        return transform(RetrofitClient.DATA(baseUrl).upImage(requestBody));
    }

    //=====================================校友圈=========================================、、

    /**
     * 获取校友圈动态
     */
    public Observable<RespDynamic> getAllDynamic(String baseUrl, int page, int pageSize) {
        return transform(RetrofitClient.DATA(baseUrl).getAllDynamics(page, pageSize));
    }

    /**
     * 根据id获取动态
     */
    public Observable<RespDynamic> getDynamicsById(String baseUrl, String userid, int page, int pageSize) {
        return transform(RetrofitClient.DATA(baseUrl).getDynamicsById(userid, page, pageSize));
    }

    /**
     * 发布动态
     */
    public Observable<RespCurr> publishDynamic(String baseUrl, ReqDynamics dynamic) {
        return transform(RetrofitClient.DATA(baseUrl).publishDynamic(dynamic));
    }

    /**
     * 删除动态
     */
    public Observable<RespCurr> deleteDynamic(String baseUrl, long dynamicid) {
        return transform(RetrofitClient.DATA(baseUrl).deleteDynamic(dynamicid));
    }

    /**
     * 发表动态评论
     */
    public Observable<RespCurr> publishDynamicCommit(String baseUrl, ReqCommitDynamic commitDynamic) {
        return transform(RetrofitClient.DATA(baseUrl).publishDynamicCommit(commitDynamic));
    }

    /**
     * 获取动态评论
     */
    public Observable<RespDynamicCommit> getDynamicCommit(String baseUrl, long dynamicId) {
        return transform(RetrofitClient.DATA(baseUrl).getDynamicCommit(dynamicId));
    }

    /**
     * 删除动态评论
     */
    public Observable<RespCurr> deleteDynamicCommit(String baseUrl, long commitid) {
        return transform(RetrofitClient.DATA(baseUrl).deleteDynamicCommit(commitid));
    }
    //=====================================二手书=============================================

    /**
     * 获取二手书
     */
    public Observable<RespBook> getAllSecondBook(String baseUrl, int page, int pageSize) {
        return transform(RetrofitClient.DATA(baseUrl).getAllSecondBook(page, pageSize));
    }

    /**
     * 根据id获取二手书
     */
    public Observable<RespBook> getSecondBookById(String baseUrl, String userid, int page, int pageSize) {
        return transform(RetrofitClient.DATA(baseUrl).getSecondBookById(userid, page, pageSize));
    }

    /**
     * 发布二手书
     */
    public Observable<RespCurr> publishBook(String baseUrl, ReqSecondBook book) {
        return transform(RetrofitClient.DATA(baseUrl).publishBook(book));
    }

    /**
     * 删除二手书
     */
    public Observable<RespCurr> deleteBook(String baseUrl, long bookid) {
        return transform(RetrofitClient.DATA(baseUrl).deleteBook(bookid));
    }

    /**
     * 发表动态评论
     */
    public Observable<RespCurr> publisBookCommit(String baseUrl, ReqBookCommit reqBookCommit) {
        return transform(RetrofitClient.DATA(baseUrl).publisBookCommit(reqBookCommit));
    }

    /**
     * 获取动态评论
     */
    public Observable<RespBookCommit> getBookCommit(String baseUrl, long bookid) {
        return transform(RetrofitClient.DATA(baseUrl).getBookCommit(bookid));
    }

    /**
     * 删除动态评论
     */
    public Observable<RespCurr> deleteBookCommit(String baseUrl, long commitid) {
        return transform(RetrofitClient.DATA(baseUrl).deleteBookCommit(commitid));
    }

    //======================================失物招领===========================================

    /**
     * 获取失物招领列表
     */
    public Observable<RespLosted> getLostList(String baseUrl, int page, int pageSize) {
        return transform(RetrofitClient.DATA(baseUrl).getAllLostthings(page, pageSize));
    }

    /**
     * 根据id获取失物招领
     */
    public Observable<RespLosted> getLostthingsById(String baseUrl, String userid, int page, int pageSize) {
        return transform(RetrofitClient.DATA(baseUrl).getLostthingsById(userid, page, pageSize));
    }

    /**
     * 发布失物招领
     */
    public Observable<RespCurr> addLosted(String baseUrl, ReqLostedthing lostedthing) {
        return transform(RetrofitClient.DATA(baseUrl).publishLosted(lostedthing));
    }

    /**
     * 删除失物招领
     */
    public Observable<RespCurr> deleteLosted(String baseUrl, long lostedid) {
        return transform(RetrofitClient.DATA(baseUrl).deleteLosted(lostedid));
    }

    //=====================================其他===============================================

    /**
     * 反馈意见
     */
    public Observable<RespCurr> fackIssue(String baseUrl, ReqIssue issue) {
        return transform(RetrofitClient.DATA(baseUrl).fackIssue(issue));
    }

    /**
     * 获取首页banner图
     */
    public Observable<RespHomeBanner> getHomeBanner(String baseUrl) {
        return transform(RetrofitClient.DATA(baseUrl).getHomeBanner());
    }
}
